package com.glela.statistics.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.glela.statistics.model.CommissionReport;
import com.glela.statistics.model.OrderCondition;
import com.glela.statistics.model.OrderQueryTotal;
import com.glela.statistics.model.OrderReport;
import com.glela.statistics.model.RevenueUser;
import com.glela.statistics.model.SalesAmountReport;
import com.glela.statistics.model.SalesMonthReport;
import com.glela.statistics.model.TalentOrderEntity;
import com.glela.statistics.model.TalentOrderQuantityReport;
import com.glela.statistics.model.TalentStudent;
import com.glela.statistics.model.UserEarnings;
import com.glela.statistics.model.response.CommissionResponse;
import com.glela.statistics.model.response.RevenueResponse;
import com.glela.statistics.model.response.SalesRanking;

/**
 * 订单统计
 * @author MaoZeYao
 *
 */
public interface OrderStatisticsMapper {
	
	/**
	 * 初始化讲师订单数量统计表
	 * @return
	 */
	public int initializeTableOrderReport(OrderCondition condition);
	
	/**
	 * 初始化讲师所属达人的订单
	 * @param condition
	 * @return
	 */
	public int initializeTableTalentOrderQuantityReport(OrderCondition condition);
	
	/**
	 * 初始化讲师佣金报表
	 * @param condition
	 * @return
	 */
	public int initializeTableCommisomnReport(OrderCondition condition);
	
	/**
	 * 初始化讲师销售额区间
	 * @param condition
	 * @return
	 */
	public int initializeTableSalesAmountReport(OrderCondition condition);
	
	/**
	 * 初始化讲师月销售额
	 * @param condition
	 * @return
	 */
	public int initializeTableSalesMonthReport(OrderCondition condition);
	
	/**
	 * 查询讲师的订单统计
	 * @param userId
	 * @return
	 */
	public OrderReport selectTalentTeacherOrderReport(long userId);
	
	/**
	 * 查询讲师所属的推客订单数量
	 * @param persionId
	 * @return
	 */
	public TalentOrderQuantityReport selectTalentOrderNumByTeacherPersionId(String persionId);
	
	/**
	 * 查询讲师的历史佣金统计
	 * @param userId
	 * @return
	 */
	public CommissionReport selectCommissionReportByUserId(long userId);

	/**
	 * 讲师销售区间统计
	 * @param userId
	 * @return
	 */
	public SalesAmountReport selectSalesAmountReportByUserId(long userId);
	
	/**
	 * 讲师月销售明细
	 * @param userId
	 * @return
	 */
	public SalesMonthReport selectSalesMonthReportByUserId(long userId);
	
	/**
	 * 查询讲师当月的佣金
	 * @param userId
	 * @return
	 */
	public int selectTalentTeacherMonthCommission(long userId);
	
	/**
	 * 获取销售排行
	 * @return
	 */
	public List<SalesRanking> selectSalesRankingSelfSupportTrue();
	public List<SalesRanking> selectSalesRankingSelfSupportFalse();
	
	/**
	 * 讲师订单列表
	 * @param userId
	 * @param persionId
	 * @return
	 */
	public List<TalentOrderEntity> selectTalentOrderEntityByIdAndPersionId(@Param("userId") long userId, @Param("persionId") String persionId,@Param("statusArray") int[] statusArray,@Param("startIndex") int startIndex, @Param("pageSize") int pageSize);

	/**
	 * 获取推客信息
	 * @param persionId
	 * @param startIndex
	 * @param pageSize
	 * @return
	 */
	public List<TalentStudent> selectTalentStudentByTeacherPersionId(@Param("persionId") String persionId,@Param("startIndex") int startIndex, @Param("pageSize") int pageSize);
	
	public List<String> selectAllStudentByTeacherPersionId(@Param("persionId") String persionId);

	/////////////////////////////V4.25///////////////////////
	
	/**
	 * 
	 * @param userId
	 * @param stuId
	 * @param orderInfoIds
	 * @return
	 */
	public List<TalentOrderEntity> selectOrderDetailByOrderInfoIds(@Param("userId") long userId, @Param("orderInfoIds") List<Long> orderInfoIds);

	/**
	 * 获取
	 * @param recommendFrom
	 * @param statusArray
	 * @param startIndex
	 * @param pageSize
	 * @return
	 */
	public long[] selectOrderInfoIds(@Param("recommendFrom") String recommendFrom, @Param("statusArray") int[] statusArray,@Param("startIndex") int startIndex, @Param("pageSize") int pageSize);

	/**
	 * 根据封装条件查询订单
	 * @param params
	 * @return
	 */
	public List<Long> selectOrderWithConditon(Map<String,Object> params);
	
	/**
	 * 计总
	 * @param params
	 * @return
	 */
	public OrderQueryTotal selectOrderWithConditonTotal(Map<String,Object> params);
	
	/**
	 * 讲师查所有订单
	 * @param params
	 * @return
	 */
	public List<Long> selectOrderWithConditonTeacher(Map<String,Object> params);
	
	/**
	 * 计总
	 * @param params
	 * @return
	 */
	public OrderQueryTotal selectOrderWithConditonTeacherTotal(Map<String,Object> params);

	/**
	 * 我的钱包营收明细查询
	 * @param userId
	 * @return
	 */
	public List<CommissionResponse> selectMyWalletByUserId(@Param("userId") long userId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("startIndex") int startIndex, @Param("pageSize") int pageSize);

	/**
	 * 店主通讯录
	 * @param id
	 * @param talentTeacher
	 * @return
	 */
	public List<TalentStudent> selectStoreStudentLink(Map<String, Object> queryMap);
	/**
	 * 店主通讯录数量
	 * @param id
	 * @return
	 */
	public Long selectStoreStudentNum(Map<String, Object> queryMap);
	
	/**
	 * 店铺中心店铺查询
	 * @param params
	 * @return
	 */
	public List<TalentStudent> selectStoreCenterStudents(Map<String, Object> queryMap);

	/**
	 * 营收明细查询
	 * @param queryMap
	 * @return
	 */
	public List<RevenueUser> selectRevenueDetails(Map<String, Object> queryMap);

	/**
	 * 讲师营收明细查询
	 * @param queryMap
	 * @return
	 */
	public RevenueUser selectRevenueDetailsTeacher(Map<String, Object> queryMap);
	
	/**
	 * 计总
	 * @param queryMap
	 * @return
	 */
	public List<RevenueResponse> selectRevenueTotal(Map<String, Object> queryMap);
	
	public List<Map<Object,Object>> validationCommision();
	public List<Map<Object,Object>> validationJournal();
	public List<Map<Object,Object>> validationUserMoney();
	public List<Map<Object,Object>> validationUserMoneyProcess();

	public List<Map<Object, Object>> validationUserPointProcess();
	
	public List<Map<String, Object>> validationUserInfo();

	public void initializeGoodsSalesCount(@Param("beginDate")String beginDate,@Param("endDate")String endDate,@Param("limits") int limits);

	/**
	 * 累计收益
	 * @param userID 用户id
	 *  @author gwq
	 * */
	public List<Long> selectAccumulatedEarningsCommision(@Param("userID")Long useID,@Param("StatusArray")int [] StatusArray);
	
	/**
	 * 今日收益
	 * @param userID 用户id
	 *  @author gwq
	 * */
	public List<Long> selectTodayEarningsCommision(@Param("userID")Long useID,@Param("StatusArray")int [] StatusArray,@Param("beginDate")String beginDate,@Param("endDate")String endDate);
	
	/**
	 * 待收收益
	 * @param userID 用户id
	 *  @author gwq
	 * */
	public List<Long> selectUncollectedEarningsCommision(@Param("userID")Long useID,@Param("StatusArray")int [] StatusArray);

	/**
	 * 未到账收益计算 妆币
	 * @param userID 用户id
	 * @param statusArry 支付状态集合
	 * @param payTimeBegin 支付开始时间
	 * @param payTimeEnd 支付结束时间
	 *  @author gwq
	 * */
	public Long selectAccumulatedEarningsPoint(@Param("userID")Long useID,@Param("statusArry")Integer[] statusArry,@Param("payTimeBegin")String payTimeBegin,@Param("payTimeEnd")String payTimeEnd);
	/**
	 * 计算佣金流水总和
	 * @param userID 用户id
	 * @param NotstatusArry 不在分类中的类型
	 * @param TimeBegin 创建时间开始
	 * @param TimeEnd 创建时间结束
	 *  @author gwq
	 * */
	public Long selectAccumulatedEarningsCommisionjournal(@Param("userID")Long useID,
	@Param("NotstatusArry")Integer[] NotstatusArry,@Param("TimeBegin")String TimeBegin,@Param("TimeEnd")String TimeEnd);
	
	/**
	 * 计算妆币流水总和
	 * @param userID 用户id
	 * @param NotstatusArry 不在分类中的类型
	 * @param TimeBegin 创建时间开始
	 * @param TimeEnd 创建时间结束
	 *  @author gwq
	 * */
	public Long selectAccumulatedEarningsPointjournal(@Param("userID")Long useID,@Param("NotstatusArry")Integer[] NotstatusArry,@Param("TimeBegin")String TimeBegin,@Param("TimeEnd")String TimeEnd);

	/**
	 * 计算累计佣金流水
	 * @param userID 用户id
	 * @param NotstatusArry 不在分类中的类型
	 * @param NocommonetArry 备注中不包含
	 *  @author gwq
	 * */
	public Long selectAllAccumulatedEarningsCommisionjournal(@Param("userID")Long useID,
	@Param("NotstatusArry")Integer[] NotstatusArry,@Param("NocommonetArry")String[] NocommonetArry);
	
	/**
	 * 计算累计妆币流水
     * @param userID 用户id
	 * @param NotstatusArry 不在分类中的类型
	 *  @author gwq
	 * */
	public Long selectAllAccumulatedEarningsPointjournal(@Param("userID")Long useID,
			@Param("NotstatusArry")Integer[] NotstatusArry);

	/**
	 * 【 本月销售额】：累计当前自然月所有已支付订单（买卖两种）支付金额总和（实付款+余额）
	 * */
	public List<Map<String,Object>> selectMonthSalesVolume(@Param("userID")Long useID,@Param("payTimeBegin")String payTimeBegin,@Param("payTimeEnd")String payTimeEnd);

	List<TalentStudent> selectUnderUser(Map<String, Object> queryMap);

	Long selectUnderStoreStudentNum(Map<String, Object> queryMap);

	OrderQueryTotal selectOrderWithConditonTotalByOpenStoreUserId(Map<String, Object> queryMap);

	List<Long> selectOrderWithConditonDetailByOpenStoreUserId(Map<String, Object> queryMap);

	public List<Map<String,Object>> getcommisionbyOrderID(@Param("id")String id);
	
	public List<Map<String,Object>> getcommisionbyOrDetailID(@Param("orderDetailID")Long orderDetailID);

	public Map<String, Object> getOrderByOrderSn(@Param("OrderSn")String orderSn);

	public List<Map<String, Object>> getcommisionbyOrderSn(@Param("orderSn")String orderSn);
	
	public Map<String, Object> getOrderObjbyOrderSn(@Param("orderSn")String orderSn);

	public Map<String, Object> getOrderObjbyId(@Param("orderObjID")Long orderObjID);

	public Map<String, Object> gettotalFeebyOrderDetailID(@Param("orderDetailID")Long orderDetailID);
	
	public List<Map<String, Object>> selectOrderByUserIDs(@Param("userIDs")List<String> userIDs);
	
	public List<Map<String, Object>> selectwithdrawCashByUserIDs(@Param("userIDs")List<String> userIDs);
}
